<?php




// 处理引号，HTML标签引起的输入框显示错误，过滤字符型变量
$process_include    = array('username', 'realname');
string_pre_process($record, $process_include);



if($action == 'u.modify') {
    $can_not_modify_pass = "<input type=\"checkbox\" name=\"admin[can_not_modify_pass]\" id=\"can_not_modify_pass\" value=\"1\" onclick=\"return fun_can_not_modify_pass(this);\" checked> <label for=\"can_not_modify_pass\">不修改密码</label>";
    $display_confirm_pass   = 'none';
    $display_pass_word      = 'none';
    $can_not_modify_name    = 'readonly';
    $password_dataType      = "";
    $lab_user_data_title    = "修改系统用户";
    $cur_tab_menu           = "not_exist";
    $javascript             = <<<EOT
<SCRIPT LANGUAGE="JavaScript">
<!--
var d='inherit';
var isIE=!!window.ActiveXObject; 
if (isIE){ 
    d='';
}
function fun_can_not_modify_pass(o_chk) {
    var this_form = o_chk.form;

    var tr1 = GE('tr_pass_word');
    var tr2 = GE('tr_confirm_pass');
    if(o_chk.checked){
        GE('password').dataType = '';
        tr1.style.display = 'none';
        tr2.style.display = 'none';
    } else {
        GE('password').dataType = 'Limit';
        tr1.style.display = d;
        tr2.style.display = d;
    }
}
//-->
</SCRIPT>
EOT;
} else {
    $display_confirm_pass   = '';
    $display_pass_word      = '';
    $can_not_modify_pass    = "";
    $can_not_modify_name    = '';
    $password_dataType      = "Limit";
    $lab_user_data_title    = "新增系统用户";
    $cur_tab_menu           = "admin_add";
    $javascript             = '';
}


$chk_is_not_valid   = $record['valid'] == 1 ? '' : ' checked';
$chk_can_not_repass = $record['canrepass'] == 1 ? '' : ' checked';
$txt_lasttime   = $record['lasttime'] > 0 ? date(DATE_TIME_FORMAT, $record['lasttime']) : '尚未登录';
$txt_createtime = $record['createtime'] > 0 ? date(DATE_TIME_FORMAT, $record['createtime']) : '未知';

require($abs_admin_cppath . '/header.php');





// 取得返回字符串
$back_url   = strcode(getcookie('back_url'), 'DECODE');
if($back_url == '') $back_url   = $mod_url['li'];


?>
<?php echo $javascript ?>

<SCRIPT LANGUAGE="JavaScript" SRC="<?php echo $url_global['common']; ?>/js/Validator.js"></SCRIPT>
<script type="text/javascript" src="<?php echo $G_web_root; ?>/js/jquery.js"></script>

		<div class="datacontainer2" style="width:500px;">
<div class="header">
	<?php echo $lab_user_data_title?>
</div>
<form action="<?php echo $mod_url['save']; ?>" method="post" name="item_data" onsubmit="return Validator.Validate(this,3)">
<table BORDER="0" cellpadding="0" cellspacing="0" width="100%" class="list_table">

<TR style="display: ;">
	<TD width="120" align="right" class="caption">登录用户名：</TD>
	<TD class="cell">
		<input type="text" name="admin[username]" value="<?php echo $record['username']; ?>" class="text" 
		<?php echo $can_not_modify_name; ?>
		dataType="Require" msg="登录用户名必须填写且必须符合上述规则">
		<span class="mustfill">*</span> <?php echo $can_not_modify_pass; ?>
		<div class="hint">用户名由a～z的英文字母(不区分大小写)、0～9的数字、点、减号或下划线组成，长度为3～18个字符，只能以数字或字母开头和结尾。例如:myname_01。</div>
	</TD>
</TR>
<TR id="tr_pass_word" style="display:<?php echo $display_pass_word?>">
	<TD width="120" align="right" class="caption">登录密码：</TD>
	<TD class="cell">
		<input type="password" name="admin[password]" id='password' value="" class="text"
		dataType="<?php echo $password_dataType?>" min="6" max="30" msg="登录密码必须填写且必须符合上述规则">
		<span class="mustfill">*</span>
		<div class="hint">密码可由除半角字符“'”和“"”以外的可打印字符组成(区分大小写)，长度为6～30个字符。 <br>修改用户信息时如果不填写本项则不修改用户登录密码。</div>
	</TD>
</TR>
<TR id="tr_confirm_pass" style="display:<?php echo $display_confirm_pass?>">
	<TD width="120" align="right" class="caption">确认密码：</TD>
	<TD class="cell"><input type="password" name="admin[confirmpass]" value="" class="text"
		dataType="Repeat" to="password" msg="两次输入的密码不一致">
		<span class="mustfill">*</span>
		<div class="hint">请确认一次您刚才输入的密码使之同“<B>登录密码</B>”项保持一致。</div>
	</TD>
</TR>

<TR>
	<TD width="120" align="right" class="caption">真实姓名：</TD>
	<TD class="cell">
		<input type="text" name="admin[realname]" value="<?php echo $record['realname']; ?>" class="text"
		dataType="Require" msg="真实姓名必须填写且长度不能超过50个字符">
		<span class="mustfill">*</span>
	</TD>
</TR>

<TR>
	<TD width="120" align="right" class="caption">拥有角色：</TD>
	<TD class="cell">


<TABLE border="0" cellpadding="2" cellspacing="2" width="98%">
<?php
$end    = true;
$cols   = 4;
$tdw    = ceil(100/$cols) . '%';
$icount = 1;

foreach($record['rrs'] as $role) {
    $checked    = '';
    if(is_array($record['relrs']) && sizeof($record['relrs']) > 0) {
        foreach($record['relrs'] as $rolerel) {
            if($role['id'] == $rolerel['rid']) {
                $checked    = 'checked';
                break;
            }
        }
    }


    $end = false;
    if(($icount-1)%$cols == 0) echo "<TR>";
?>
<TD width="<?php echo $tdw; ?>"><INPUT TYPE="checkbox" NAME="admin[rid][]" ID="rid_<?php echo $role['id']; ?>" VALUE="<?php echo $role['id']; ?>" <?php echo $checked; ?>> <label for="rid_<?php echo $role['id']; ?>"><?php echo $role['rolename']; ?></label></TD>
<?php
    if($icount%$cols == 0) {
        echo "</TR>";
        $end = true;
    }
    $icount ++;
}
if(!$end) {
    $endcount = $cols-($icount-1)%$cols;
    for($i=$endcount; $i>0; $i--) {
        echo "<TD width=\"$tdw\">&nbsp;</TD>";
    }
    echo "</TR>";
}elseif($end && sizeof($record['rrs']) <= 0) {
    echo "<TR><TD>&nbsp;</TD></TR>";
}
?>

</TABLE>


	</TD>
</TR>
<TR>
	<TD width="120" align="right" class="caption">创建时间：</TD>
	<TD class="cell"><span class="time01"><?php echo $txt_createtime; ?></span></TD>
</TR>
<TR>
	<TD width="120" align="right" class="caption">最近登录：</TD>
	<TD class="cell"><span class="time01"><?php echo $record['lastip']; ?>@<?php echo $txt_lasttime; ?></span></TD>
</TR>
<TR>
	<TD class="cell" colspan="2">
		<input type="checkbox" name="admin[is_not_valid]" id="is_not_valid" value="1" <?php echo $chk_is_not_valid ?>> <label for="is_not_valid">帐户已禁用</label> <br>
		<!-- <input type="checkbox" name="admin[can_not_repass]" id="can_not_repass" value="1" <?php echo $chk_can_not_repass ?>>  <label for="can_not_repass">用户不能更改密码</label> -->
	</TD>
</TR>
<TR>
	<TD width="120" align="right" class="caption">描述信息：</TD>
	<TD class="cell"><textarea rows="5" cols="10" 
		name="admin[description]" class="area" style="width:90%"
		dataType="Limit" max="512" msg="描述信息长度不能超过512个字符"><?php echo $record['description']; ?></textarea>
	</TD>
</TR>
<TR>
	<TD class="submit" colspan="2">
		<input type="submit" value=" 保存 " class="btn">
		<input type="reset" value=" 重置 " class="btn">
		<input type="button" value=" 返回 " class="btn" onclick="location.href='<?php echo $back_url; ?>'">
		<input type="hidden" name="back_url" value="<?php echo $back_url; ?>">
		<input type="hidden" name="admin[uid]" value="<?php echo $record['uid']; ?>">
		<input type="hidden" name="save" value="<?php echo $save_flag; ?>">
	</TD>
</TR>

</TABLE>
</form>
		</div>


<script>
var d='inherit';
var isIE=!!window.ActiveXObject; 
if (isIE){ 
    d='';
}
ch1('<?php echo $record['qx'];?>');
function ch1(x){
    if(x=='2'){
        $('#ch1').css('display','none');
        $('#ch2').css('display','none');
        $('#ch4').css('display',d);
        $('#ch5').css('display',d);
    }else if(x=='3'){
        $('#ch1').css('display',d);
        $('#ch2').css('display',d);
        $('#ch4').css('display','none');
        $('#ch5').css('display','none');
    }else{
        $('#ch1').css('display','none');
        $('#ch2').css('display','none');
        $('#ch4').css('display','none');
        $('#ch5').css('display','none');
    }
}
function sszd(x){
	var url	= '<?php echo $G_web_root;?>/ajax/getcity.php?city='+x;
	$.get(url,function(data){
			$("#city_list").html(unescape(data));
	});
}
<?php if($record['city']){?>
    var url	= '<?php echo $G_web_root;?>/ajax/getcity.php?city=510000&not=y&sel=<?php echo $record['city'];?>';
	$.get(url,function(data){
			$("#city").html(unescape(data));
	});
    <?php if($record['city1']){?>
    var url	= '<?php echo $G_web_root;?>/ajax/getcity.php?city=<?php echo $record['city'];?>&sel=<?php echo $record['city1'];?>';
	$.get(url,function(data){
			$("#city_list").html(unescape(data));
	});

<?php }
    else{
        ?>
        var url	= '<?php echo $G_web_root;?>/ajax/getcity.php?city=<?php echo $record['city'];?>&sel=0';
    	$.get(url,function(data){
    			$("#city_list").html(unescape(data));
    	});
        <?php 
    }
}else{
    ?>
    var url	= '<?php echo $G_web_root;?>/ajax/getcity.php?city=510000&not=y';
	$.get(url,function(data){
			$("#city").html(unescape(data));
	});
    var url	= '<?php echo $G_web_root;?>/ajax/getcity.php?city=510100&sel=0';
	$.get(url,function(data){
			$("#city_list").html(unescape(data));
	});
    <?php
}

?>
</script>
<?php
require($abs_admin_cppath . '/footer.php');
?>